package com.twu.biblioteca.model;

import java.util.List;

public class Book implements Item {
    private String id;
    private String title;
    private List<String> authors;
    private boolean isAvailable;

    public Book(String id, String title, List<String> authors) {
        this.id = id;
        this.title = title;
        this.authors = authors;
        this.isAvailable=true;
    }

    @Override
    public void printDetails() {
        System.out.println(String.format("%s\t\t\t%s\t%s", id,title,authors));
    }

    @Override
    public String getId() {
        return id;
    }

    @Override
    public boolean isAvailable(){
        return isAvailable;
    }

    public void setAvailable(){
        this.isAvailable = true;
    }

    public void setUnAvailable(){
        this.isAvailable = false;
    }

     @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Book book = (Book) o;

        if (!id.equals(book.id)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }
}
